package EMAIL_VISION::Tracker::API::EmailVisionHTTPRequest;

use base qw (Exporter);
use strict;

use DE_EPAGES::Core::API::Log qw (LogDebug GetLog);
use EMAIL_VISION::Tracker::API::UriGenerator;
use DateTime;
use Data::Dumper;
use LWP::UserAgent;
use URI::Escape;

sub SendHTTPRequest 
{
	GetLog->debug("EmailVision SendHTTPRequest function triggered...");

	my ($hParams) = @_;
	my $Order = $hParams->{"Order"};

        my $uriGen = new EMAIL_VISION::Tracker::API::UriGenerator($Order);
	my $uri = $uriGen->getUri();
	
	GetLog->debug("EV URI: ",$uri);
	
	if($uri) {                
            my $agent = LWP::UserAgent->new;
            $agent->agent("Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2) Gecko/20100130 Gentoo Firefox/3.6");
            my $req = HTTP::Request->new(GET => $uri);
            $req->content_type('application/x-www-form-urlencoded');
            $req->content('query=libwww-perl&mode=dist');
            my $response = $agent->request($req);
            if ($response->is_success) {
               	GetLog->debug("Email Vision Success Response: ",$response->content);
            } else {
              	GetLog->debug("Email Vision Fail Response: ",$response->status_line);
            }
        }


	#GetLog->debug("Order: ",Dumper($Order));
	return;
}

1;
